import { createApp, h } from "vue";

import App from "./App.vue";

import { createWebHashHistory, createRouter } from "vue-router";

import Home from "./views/Home.vue";
import Shop from "./views/Shop.vue";
import Cart from "./views/Cart.vue";
import NotFound from "./views/NotFound.vue";

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    { path: "/home", component: Home },
    // /shop/1
    // /shop/jack
    { path: "/shop/:id", component: Shop },
    // 查询字符串参数
    // /cart/100/shop/20?name=jack&age=20&gender=boy
    { path: "/cart/:id/shop/:sid", component: Cart },
    // 兜底
    { path: "/:x(.*)*", component: NotFound },
  ],
});

const app = createApp({ render: () => h(App) });

app.use(router);

app.mount("#app");
